import { Body, Controller, Post, HttpException } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { LoginService } from '../services/login.service'
import { LoginDto } from '../dtos/login.dto'
import { md5Create } from '../utils/md5Create'

@Controller('/login')
@ApiTags('登录')
export class LoginController {
  constructor (private readonly loginService: LoginService) { }

  @Post()
  @ApiOperation({ summary: '登录' })
  async login(@Body() LoginDto: LoginDto) {
    try {
      LoginDto.fUserPassword = md5Create(LoginDto.fUserPassword)
      return await this.loginService.loginService(LoginDto)
    } catch (error) {
      throw new HttpException(error.response, error.status)
    }
  }
}